CREATE TABLE [dbo].[TCREPO_FINA]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[TI_REPO] [dbo].[TD_VC_001] NOT NULL,
[TI_REPO_EMPR] [dbo].[TD_VC_001] NOT NULL,
[CO_REPO] [dbo].[TD_VC_003] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TCREPO_FI__NU_AN__5812160E] DEFAULT (datepart(year,getdate())),
[DE_REPO] [dbo].[TD_VC_100] NULL,
[ST_REPO] [dbo].[TD_VC_001] NOT NULL,
[ST_CNTA_EMPR] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TCREPO_FI__ST_CN__59FA5E80] DEFAULT ('N'),
[ST_TIPO_AUXI] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TCREPO_FI__ST_TI__5BE2A6F2] DEFAULT ('N'),
[ST_CODI_AUXI] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TCREPO_FI__ST_CO__5DCAEF64] DEFAULT ('N'),
[ST_ORDE_SERV] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TCREPO_FI__ST_OR__5FB337D6] DEFAULT ('N'),
[CO_USUA_INGR] [dbo].[TD_VC_008_USUA] NOT NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCREPO_FI__FE_US__619B8048] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCREPO_FI__FE_US__628FA481] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [CK__TCREPO_FI__NU_AN__59063A47] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [CK__TCREPO_FI__ST_CN__5AEE82B9] CHECK (([ST_CNTA_EMPR]='N' OR [ST_CNTA_EMPR]='S'))
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [CK__TCREPO_FI__ST_CO__5EBF139D] CHECK (([ST_CODI_AUXI]='N' OR [ST_CODI_AUXI]='S'))
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [CK__TCREPO_FI__ST_OR__60A75C0F] CHECK (([ST_ORDE_SERV]='N' OR [ST_ORDE_SERV]='S'))
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [CK__TCREPO_FI__ST_TI__5CD6CB2B] CHECK (([ST_TIPO_AUXI]='N' OR [ST_TIPO_AUXI]='S'))
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [CK__TCREPO_FI__TI_RE__5629CD9C] CHECK (([TI_REPO]='C' OR [TI_REPO]='E'))
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [CK__TCREPO_FI__TI_RE__571DF1D5] CHECK (([TI_REPO_EMPR]='C' OR [TI_REPO_EMPR]='F' OR [TI_REPO_EMPR]='P'))
GO
ALTER TABLE [dbo].[TCREPO_FINA] ADD CONSTRAINT [XPKTCREPO_FINA] PRIMARY KEY CLUSTERED  ([CO_EMPR], [TI_REPO], [TI_REPO_EMPR], [CO_REPO], [NU_ANNO]) ON [PRIMARY]
GO
